package com.xjscrm.console.web.operatePlan;

import com.xjscrm.common.entity.OperatePlan;
import com.xjscrm.console.param.operatePlan.*;
import com.xjscrm.console.service.customer.operatePlan.OperatePlanService;
import com.xjscrm.console.vo.EffectuateGroupVo;
import com.xjscrm.console.vo.OperatePlanDeviceVo;
import com.xjscrm.console.vo.WwFriendReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "客户方案管理", tags = "客户方案管理")
@RestController
@RequestMapping(value = "/operatePlan")
public class OperatePlanController {

    @Autowired
    private OperatePlanService operatePlanService;

    @ApiOperation(value = "新增客户方案", notes = "新增客户方案", response = Boolean.class)
    @PostMapping(value = {"/addOperatePlan", "/addCustomerOperationPlan"})
    public Object addOperatePlan(@RequestBody OperatePlanDto operatePlanDto) throws Exception {
        operatePlanService.addOperatePlan(operatePlanDto);
        return true;
    }

    @ApiOperation(value = "查询客户方案列表", notes = "查询客户方案列表", response = OperatePlan.class)
    @PostMapping(value = {"/getOperatePlan", "/getCustomerOperationPlan"})
    public Object getOperatePlan(@RequestBody OperatePlanQuery operatePlanQuery) throws Exception {
        return operatePlanService.getOperatePlan(operatePlanQuery);
    }

    @ApiOperation(value = "查询客户方案详情", notes = "查询客户方案详情", response = OperatePlan.class)
    @PostMapping(value = {"/getOperatePlanDetails", "/getCustomerOperationPlanDetails"})
    public Object getOperatePlan(@RequestBody OperatePlanDto operatePlanDto) throws Exception {
        return operatePlanService.getOperatePlanDetails(operatePlanDto);
    }

    @ApiOperation(value = "修改客户方案", notes = "修改客户方案", response = Boolean.class)
    @PostMapping(value = {"/updateOperatePlan", "/updateCustomerOperationPlan"})
    public Object updateOperatePlan(@RequestBody OperatePlanDto operatePlanDto) throws Exception {
        operatePlanService.updateOperatePlan(operatePlanDto);
        return true;
    }

    @ApiOperation(value = "删除客户方案", notes = "删除客户方案", response = Boolean.class)
    @PostMapping(value = {"/deleOperatePlan", "/deleCustomerOperationPlan"})
    public Object deleOperatePlan(@RequestBody OperatePlanDto operatePlanDto) throws Exception {
        operatePlanService.deleOperatePlan(operatePlanDto);
        return true;
    }


    @ApiOperation(value = "新增方案和机器人关系", notes = "新增方案和机器人关系", response = Boolean.class)
    @PostMapping(value = {"/addOperatePlanDevice", "/addCustomerOperationPlanDevice"})
    public Object addOperatePlanDevice(@RequestBody OperatePlanDeviceDto operatePlanDeviceDto) throws Exception {
        operatePlanService.addOperatePlanDevice(operatePlanDeviceDto);
        return true;
    }


    @ApiOperation(value = "获取方案和机器人关系列表", notes = "获取方案和机器人关系列表", response = OperatePlanDeviceVo.class)
    @PostMapping(value = {"/getOperatePlanDevice", "/getCustomerOperationPlanDevice"})
    public Object getOperatePlanDevice(@RequestBody OperatePlanDeviceQuery operatePlanDeviceQuery) throws Exception {
        return operatePlanService.getOperatePlanDevice(operatePlanDeviceQuery);
    }

    @ApiOperation(value = "修改方案和机器人关系的应用规则", notes = "修改方案和机器人关系的应用规则", response = Boolean.class)
    @PostMapping(value = {"/updateOperatePlanDevice", "/updateCustomerOperationPlanDevice"})
    public Object updateOperatePlanDevice(@RequestBody OperatePlanDeviceDto operatePlanDeviceDto) throws Exception {
        operatePlanService.updateOperatePlanDevice(operatePlanDeviceDto);
        return true;
    }

    @ApiOperation(value = "批量修改方案和机器人关系的应用规则", notes = "批量修改方案和机器人关系的应用规则", response = Boolean.class)
    @PostMapping(value = {"/updateOperatePlanDevice/batch", "/updateCustomerOperationPlanDevice/batch"})
    public Object batchUpdateOperatePlanDevice(@RequestBody OperatePlanDeviceDto operatePlanDeviceDto) throws Exception {
        operatePlanService.batchUpdateOperatePlanDevice(operatePlanDeviceDto);
        return true;
    }

    @ApiOperation(value = "删除方案和机器人关系", notes = "删除方案和机器人关系", response = Boolean.class)
    @PostMapping(value = {"/deleOperatePlanDevice", "/deleCustomerOperationPlanDevice"})
    public Object deleOperatePlanDevice(@RequestBody OperatePlanDeviceDto operatePlanDeviceDto) throws Exception {
        operatePlanService.deleOperatePlanDevice(operatePlanDeviceDto);
        return true;
    }

    @ApiOperation(value = "批量删除方案和机器人关系", notes = "批量删除方案和机器人关系", response = Boolean.class)
    @PostMapping(value = {"/bathdeleOperatePlanDevice", "/bathdeleCustomerOperationDevice"})
    public Object bathdeleOperatePlanDevice(@RequestBody BathdeleOperatePlanDeviceDto bathdeleOperatePlanDeviceDto) throws Exception {
        operatePlanService.bathdeleOperatePlanDevice(bathdeleOperatePlanDeviceDto);
        return true;
    }

    @ApiOperation(value = "获取新客接受请求记录列表", notes = "获取新客接受请求记录列表", response = WwFriendReqVo.class)
    @PostMapping(value = "/getWwFriendReq")
    public Object getWwFriendReq(@RequestBody WwFriendReqQuery wwFriendReqQuery) throws Exception {
        return operatePlanService.getWwFriendReq(wwFriendReqQuery);
    }


    @ApiOperation(value = "手动通过好友", notes = "手动通过好友", response = Boolean.class)
    @PostMapping(value = "/thoughFriends")
    public Object thoughFriends(@RequestBody WwFriendReqDto wwFriendReqDto) throws Exception {
        operatePlanService.thoughFriends(wwFriendReqDto);
        return true;
    }


    @ApiOperation(value = "查看新客运营方案是否绑定了机器人", notes = "查看新客运营方案是否绑定了机器人", response = Boolean.class)
    @PostMapping(value = "/checkBandingDevice")
    public Object checkBandingDevice(@RequestBody OperatePlanDeviceDto operatePlanDeviceDto) throws Exception {
        return operatePlanService.checkBandingDevice(operatePlanDeviceDto);
    }

    @ApiOperation(value = "获取生效群", notes = "获取生效群", response = EffectuateGroupVo.class)
    @PostMapping("/getEffectuateGroup")
    public Object getEffectuateGroup(@RequestBody EffectuateGroupDto effectuateGroupDto)throws Exception{
        return operatePlanService.findAddFangetEffectuateGroupGroup(effectuateGroupDto);
    }
}
